//
//  PreferentialTableViewCell.m
//  ClassRoom
//
//  Created by apple on 12-11-17.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "PreferentialTableViewCell.h"

@implementation PreferentialTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 80, 110)];
        _image.backgroundColor = [UIColor clearColor];
        [self addSubview:_image];
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(90, 10, 230, 25)];
        _title.backgroundColor = [UIColor clearColor];
        _title.font = [UIFont fontWithName:@"Helvetica-Bold" size:23];
        [self addSubview:_title];
        
        _time = [[UILabel alloc] initWithFrame:CGRectMake(95, 90, 200, 15)];
        _time.backgroundColor = [UIColor clearColor];
        _time.font = [UIFont systemFontOfSize:15];
        [self addSubview:_time];
        
        _intro = [[UILabel alloc] initWithFrame:CGRectMake(95, 30, 200, 60)];
        _intro.backgroundColor = [UIColor clearColor];
        _intro.font = [UIFont systemFontOfSize:17];
        [self addSubview:_intro];
        
        UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(295, 50, 13, 20)];
        image.image = [UIImage imageNamed:@"Arrowhead_Green"];
        [self addSubview:image];
    }
    return self;
}

- (void)setCellData:(NSDictionary *)data{
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"courseName"]) {
        _title.text = [[data objectForKey:@"information"] objectForKey:@"courseName"];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"startTime"]) {
        _time.text = [[data objectForKey:@"information"] objectForKey:@"startTime"];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"address"]) {
        _intro.lineBreakMode = UILineBreakModeTailTruncation;
        _intro.numberOfLines = 2;
        _intro.text = [[data objectForKey:@"information"] objectForKey:@"address"];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)dealloc{
    [_image release];
    [_title release];
    [_time release];
    [_intro release];
    
    [super dealloc];
}

@end
